package com.eric.project;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    public static final String TAG = MainActivity.class.getSimpleName() + "======> ";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView  txt_eventView  = (TextView) findViewById(R.id.txt_eventView);
        //
        txt_eventView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e(TAG,"      onClick        ");
            }
        });
        //如果不设置触摸监听不会触发onTouchEvent方法
        txt_eventView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        Log.e(TAG,"    onTouch->ACTION_DOWN ");
                        break;
                    case MotionEvent.ACTION_MOVE:
                        Log.e(TAG,"    onTouch->ACTION_MOVE ");
                        break;
                    case MotionEvent.ACTION_UP:
                        Log.e(TAG,"     onTouch->ACTION_UP ");
                        break;
                }
                return false;
            }
        });
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG,"dispatchTouchEvent->ACTION_DOWN ");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.e(TAG,"dispatchTouchEvent->ACTION_MOVE ");
                break;
            case MotionEvent.ACTION_UP:
                Log.e(TAG,"dispatchTouchEvent->ACTION_UP ");
                break;

        }
        return super.dispatchTouchEvent(event);
    }
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG,"onTouchEvent->ACTION_DOWN ");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.e(TAG,"onTouchEvent->ACTION_MOVE ");
                break;
            case MotionEvent.ACTION_UP:
                Log.e(TAG,"onTouchEvent->ACTION_UP ");
                break;
        }
        return super.onTouchEvent(event);
    }
}
